home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-17 | 17.3 KB | 475 lines | [TEXT/MPS ] |
- #
- # ****************************************************************************
- #
- # File Name: Globals.Lib
- #
- # Contains: xxx put contents here xxx
- #
- # Written by: Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
- #
- # Copyright: © 1993 by Apple Computer, Inc., all rights reserved.
- #
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- #
- # Vers Date Author Description
- # ---- -------- ------ ---------------------------------------------
- # <1.0.112> 12/16/93 KTA Changed gFileToolOutput to gTestCaseLoggingMethod
- # <1.0.111> 12/14/93 KTA Removed Palantino from default gFontList.
- # <1.0.110> 12/2/93 KTA Fixed bug where it was not possible to set the randomSeed value
- # from the Custom.Lib.
- # <1.0.19> 9/23/93 KTA Moved gPreflight from TCS.Lib so it would be initialized at the
- # right time.
- # <1.0.18> 9/22/93 KTA Removed global gStopTimer it was not used, removed gScriptLevel
- # from globals, removed kScrapStyledTEXT, etc.
- # <1.0.17> 9/13/93 KTA Updated TestLevel specification.
- # <1.0.16> 9/10/93 KTA Added a definable test level for application specific tests -
- # gAppTestLevel.
- # <1.0.15> 9/2/93 KTA Fixed example in SetTestLevel()
- # <1.0.14> 9/1/93 KTA Added task ExitVU, and task reference to it - gExitVU.
- # <1.0.13> 8/25/93 KTA Added support for parity checking the TCS stack and Script
- # parameter to set test level.
- # <1.0.12> 8/20/93 KTA Moved TCS specific Globals, added gFileToolOutput and
- # gNoteBookOutput for FileTool output of Phoenix data.
- # <1.0.11> 7/20/93 KTA Bug Fix: I wiped out gBuildVers when fixing gIsSys7.
- # <1.0.10> 7/19/93 KTA Added customiation support: Dependancy on Custom.lib, call
- # InitCustom().
- # <1.0.9> 7/15/93 KTA Added TCSExpCount, and made a better check for gIsSys7 (for
- # PowerPC).
- # <1.0.8> 7/14/93 KTA Place some global variable strings into resources for
- # international support. gScraptitle, gFontlist, gFontStyleList,
- # gFontSizeList.
- # <1+> 5/21/93 NAGA Adding header and porting old files to follow new standards
- #
- # ****************************************************************************
- #
-
- ########################################################################
- # External libraries
- #=======================================================================
- Libraries "Custom.Lib";
-
- #########################################################################
- #################### GLOBALS #####################
- #########################################################################
- ### Global Library Definitions
- ### Generally:
- ### If current value is 0 or 1, new value must be a 0 or 1
- ### If current value is true or false, new value must be true or false
- ### If current value is a string, new value must be a string
- ### If current value is a list, new value must be a list.
- ###
- #########################################################################
- #########################################################################
- # InitGlobals()
- #========================================================================
- # Author: Kevin Avoy
- # Description: Initializes most global variables used by the SPEC S&L.
- # This Task should be called prior to making any calls to
- # any tasks contained within the SPEC S&L Libraries
- # Please refer to 'The Hitchhikers Guide' for more information
- # concerning any individual global.
- # Parameters: None
- # Returns: Nothing
- # Examples: InitGlobals();
- # Assumptions:
- #========================================================================
- # History:
- # KTA 7/8/93 Added String Resources (intl)
- # KTA 7/14/93 Updated gIsSys7 check for PowerPC
- #########################################################################
- TASK InitGlobals(pTheScriptParam := -1)
- begin
-
- ############## Misc Globals ############
- global gLogLevel := 5; # Specifies the which logstr calls will be output
- global gAppVerify := 1; # 1 to verify the application is expected
- global gTargetCheck := 1; # 1 for target title; 2 for target application title
- global gTestCaseLoggingMethod := 0; # Output Test Case records
- global gNoteBookOutput := 1; # Output DataBase records to the NoteBook
- global gExitVU := Task ExitVU; # Task reference for exiting
-
- ############## Misc constants ############
- global gDebugFlag := 0; # Debugging values
-
- global gTextStr := "How jumping gymnasts will level six piqued frogs, Jim!";
-
- ############## ScrapBook Constants ############
- global kScrapTEXT := 1; # ScrapItem location of TEXT
- global kScrapPICT := 2; # ScrapItem location of PICT
-
- ############## Script Globals ############
- global gAliasDirectory := "#Aliases"; # Location of Core app aliases ( found in Apple Menu )
- global gDBLogging := 1; # Set to true to do Suite & TCS logging
- global gPreFlight := 1; # Set to true if you want to be sure target can
- # run app (see PreFlight task)
-
- match[target t:?machineName];
- global gMachineName := machineName;
-
- ############## String Resources (intl) ############
- global gScrapTitle := getString(1000);
-
- #======= font characteristic lists =======
- global gFontList := BuildListFromResource(2000);
- global gFontSizeList := BuildListFromResource(2001);
- global gFontStyleList := BuildListFromResource(2002);
-
-
- ############################################################################
- # gSFPUTLocation contains the path to the directory in which files will be saved
- # by the NameOK Task. If the list is empty files will be saved in the default dir
- # IMPORTANT: gSFPUTLocation is a list
- # for example: global gSFPUTLocation := {"myDisk"};
- ############################################################################
- global gSFPUTLocation := {};
-
- ############## Print Global ############
- global gPrintTest := 0; # If true print test will be executed
-
- ############## DoWindows Globals ############
- global gDoWindowList := {1,1,1,1};
- # Set each element to 1 or 0. Flag for performing DoWindows tests as follows:
- # Element: 1 - Sizing
- # 2 - Scrolling
- # 3 - Dragging
- # 4 - Zooming
-
- ############## Launching/Quitting Globals ##################################
- # Quit() will close all windows, Launchtwitch() will background quit apps
- global gBackgroundQuit := 0;
-
- # Overrides gBackgroundQuit. Quit() does nothing, Launchtwitch() will
- # twitch to and quit apps until it can complete launch.
- global gForceQuit := 0;
-
- # Quit() will attempt to twitch to gFillMemApp and quit it. Launchtwitch(AppName)
- # will attempt to launch gFillMemApp after AppName.
- global gFillMemory := 0;
-
- # The name of the app you want to fill memory with. Set it's memory allocation
- # high enough to use up all additional memory, place it's alias in the apple menu or
- # in the alias directory.
- global gFillMemApp := 'TeachText';
-
-
- ############## Random Seeding Globals ##################################
- global gSeedZero := 0; # set to 1 if seed value needs to be zero (very unlikely!)
- # don't change unless you are sure - overrides gSeedValue!
- global gSeedValue:= 0; # set seed value if reproducing tests, otherwise leave at 0
-
-
- ############################################################################
- ####### DO NOT modify any of the following GLOBAL Settings - ############
- ####### DisableAllLogging may be reset during script execution ############
- ############################################################################
- ### Updated gIsSys7 check for PowerPC
- SystemCheck := Gestalt('sysv');
- myError := ScriptError();
- if not(SystemCheck[1]) and not(myError)
- begin
- SystemVersion := SystemCheck[2][2];
- if (SystemVersion >= 1792) # 1792 is 0700 in Hex for system 7.0
- Global gIsSys7 := 1; # System7 features are available
- Else
- gIsSys7 := 0; # System7 features are not available
- end;
- else # Gestalt may not be installed. Exit for now
- begin
- Println "Sorry, a gestalt error occured - ", systemCheck[1];
- call (global gExitVU);
- end;
- match[system v:?SysName];
- global gBuildVers := "{SysName}";
- global gLogStrCount := 0; # Initializes the counter used by LogStr
- global gAppTitle := ""; # Current application title for AppVerify()
- global gAppVersion := ""; # Version of current application
- global gPrevAppTitle := ""; # Previous application title (for twitching back)
- global gDisableAllLogging := 0; # 1 if no logging (run time modify only)
- if (global gDisableAllLogging)
- Global gLogLevel := 0;
- global gSFOriginalPath := {}; # Holds pathlist of Standard File before you navigate
-
- if(TypeOf(pTheScriptParam) = 'list')
- SetTestLevel(pTheScriptParam[1],pTheScriptParam[2]);
- else if(TypeOf(pTheScriptParam) = 'integer')
- begin
- if(pTheScriptParam = -1) # Default setting for the scriptParam
- SetTestLevel(1); # Default to Quicklook
- else
- SetTestLevel(pTheScriptParam);
- end;
-
- InitCustom(); # Call to initalize any custom defined globals
- InitRandomSeed();
- end;
-
- #########################################################################
- # InitRandomSeed()
- #========================================================================
- # Author: ML
- # Description: Initializes the random seed.
- # Parameters: None
- # Returns: Nada
- # Examples: InitRandomSeed();
- # Assumptions:
- #========================================================================
- # History:
- #
- ########################################################################
- TASK InitRandomSeed()
- begin
-
- if global gSeedZero = 1 # if you want to seed 0
- global gSeedValue:=0;
- else # else non zero seed
- begin
- if not (gSeedValue) # if you don't want to seed
- gSeedValue:= random(); # generate a random seed
- end;
-
- randomseed(gSeedValue); # seed the random number generator
-
- println "The seed value is ",gSeedValue; # print out the seed value for posterity
-
- end;
-
- #########################################################################
- # PrintGlobals()
- #========================================================================
- # Author: NJV
- # Description: Prints the values of all Control Globals
- # Parameters: None
- # Returns: Nothing
- # Examples: PrintGlobals();
- # Assumptions: None
- #========================================================================
- # History:
- #
- #########################################################################
- TASK PrintGlobals()
- begin
-
- if (global gAppVerify)
- println "The 'Application Verification' scheme is turned - ON";
- else
- println "The 'Application Verification' scheme is turned - OFF";
-
- if (global gTargetCheck)
- println "The global 'gTargetCheck' is set to output - the title of the target's current 'Application'";
-
- ############## Print Font Globals ############
- if (global gFontList) begin
- print "The global 'gFontList' is : '";
- fntCount := Card(gFontList);
- For timeThru := 1 to fntCount begin
- print gFontList[timeThru];
- if not(timeThru = fntCount)
- Print "', '";
- end;
- Println "'";
- end;
-
- if (global gFontSizeList) begin
- print "The global 'gFontSizeList' is : '";
- fntSZCount := Card(gFontSizeList);
- For timeThru := 1 to fntSZCount begin
- print gFontSizeList[timeThru];
- if not(timeThru = fntSZCount)
- Print "', '";
- end;
- Println "'";
- end;
-
- if (global gFontStyleList) begin
- print "The global 'gFontStyleList' is : '";
- fntSTLCount := Card(gFontStyleList);
- For timeThru := 1 to fntSTLCount begin
- print gFontStyleList[timeThru];
- if not(timeThru = fntSTLCount)
- Print "', '";
- end;
- Println "'";
- end;
-
- if (global gTextStr)
- println "The global gTextStr is set to - '{gTextStr}'";
-
- ############## Print ScrapBook Globals ############
- if (global kScrapTEXT)
- println "kScrapText is set to - '{kScrapTEXT}'";
-
- if (global kScrapPICT)
- println "kScrapPICT is set to - '{kScrapPICT}'";
-
- ############## Print Script Globals ############
- if (global gAliasDirectory)
- println "gAliasDirectory is set to - '{gAliasDirectory}'";
-
- ############## Print Other Globals ############
- if (global gLogLevel)
- println "gLogLevel is set to '{gLogLevel}'";
- else
- println "All logging is disabled";
-
- Println "The current system is - '{global gBuildVers}'";
-
- if (global gSFPUTLocation)
- begin
- SFPath := "";
- for each item in gSFPUTLocation
- SFPath := SFPath + Item + ":";
- Println "SF_Put is set to navigate to '{SFPath}'";
- end;
- else
- println "SF_Put will save to the default directory";
- end; # PrintGlobals()
- #########################################################################
- # BuildListFromResource( idNum )
- #========================================================================
- # Author: Kevin Avoy (ext. 45604)
- # Description: Returns a list generated from all of the strings in a specified
- # string list resource <idNum>.
- # Parameters: idNum := resource id number for the string list resource.
- # Returns: list - all strings in specified string list resource.
- # Examples: BuildListFromResource( 1000 );
- # Assumptions: This task must be contained within the same file that contains
- # the resources.
- #========================================================================
- # History:
- #
- #########################################################################
- task BuildListFromResource(idNum)
- begin
- numtimes := 100; #Assumes no resource will contain more than 100 strings
- theList := {};
- for i := 1 to numtimes
- begin
- CurrentItem := GetIndString(idNum,i);
- #Println "This is the CurrentItem - ", CurrentItem;
- if (isUndefined(CurrentItem))
- numtimes := i;
- else
- theList := Insert(CurrentItem,Card(theList)+1, theList);
- end;
- #println "This is theList - ", theList;
- return(theList);
- end;
-
-
- #########################################################################
- # SetTestLevel(pTestLevel := 1, pCustomSetting := {})
- #========================================================================
- # Author: Kevin Avoy (ext. 45604)
- # Description: Will set globals that will determine the level of testing
- # that will occur in the DoTests.
- # Parameters: pTestLevel := Generic level of testing desired.
- # 1 - least amount of testing
- # 2 - medium amount of testing
- # 3 - Most amount of testing
- # pCustomSetting - Any Custom settings, this will override the
- # generic settings for any specified global setting.
- # Returns:
- # Examples: SetTestLevel( 1, {{'Draw', {1,2}}} );
- # Assumptions:
- #========================================================================
- # History:
- # KTA 9/9/93 Added support for gAppTestLevel
- #########################################################################
- TASK SetTestLevel(pTestLevel := 1, pCustomSetting := {})
- begin
- if(pTestLevel = 0)
- begin
- println "==== The test level is '{pTestLevel}' - (Turn all DoTests - OFF) =====";
-
- global gFontLevel := 0;
- global gDrawLevel := 0;
- global gWindowLevel := 0;
- global gAppTestLevel := 0;
- end;
- else if(pTestLevel = 1)
- begin
- println "==== The test level is '{pTestLevel}' - (Minimum amount of testing) =====";
-
- global gFontLevel := 1;
- global gDrawLevel := 1;
- global gWindowLevel := 1;
- global gAppTestLevel := 1;
- end;
- else if(pTestLevel = 2)
- begin
- println "==== The test level is '{pTestLevel}' - (Medium amount of testing) =====";
-
- global gFontLevel := 2;
- global gDrawLevel := 2;
- global gWindowLevel := 2;
- global gAppTestLevel := 2;
-
- end;
- else if( pTestLevel = 3)
- begin
- println "==== The test level is '{pTestLevel}' - (Most amount of testing) =====";
-
- global gFontLevel := {2,3};
- global gDrawLevel := {2,3};
- global gWindowLevel := {2,3};
- global gAppTestLevel := 3;
- end;
-
-
- if (pCustomSetting)
- begin
- for each testLevel in pCustomSetting
- begin
- whichMethod := testLevel[1];
- testsettings := testLevel[2];
- if(whichMethod = 'DrawLevel')
- begin
- println " Custom gDrawLevel := {testsettings}";
- global gDrawLevel := testsettings;
- end;
- else if(whichMethod = 'FontLevel')
- begin
- println " Custom gFontLevel := {testsettings}";
- global gFontLevel := testsettings;
- end;
- else if(whichMethod = 'WindowLevel := {testsettings}')
- begin
- println " Custom gWindowLevel";
- global gWindowLevel := testsettings;
- end;
- else if(whichMethod = 'AppTestLevel')
- begin
- println " Custom gAppTestLevel := {testsettings}";
- global gAppTestLevel := testsettings;
- end;
- end;
- end;
- end;
-
- #########################################################################
- # ExitVU()
- #========================================================================
- # Author: Kevin Avoy
- # Description: This task makes the built in VU task Exit. The purpose
- # of defining this as a task is so we can use a task
- # reference to this task- gExitVu. This way we can default
- # our Exception Handling task to call the task reference gExitVU
- # and thus exit. If others do not want to exit they can redefine
- # the task reference to what ever task they prefer.
- # Parameters: None
- # Returns: Nothing
- # Examples: ExitVU(); or to use the task reference - Call(global gExitVU);
- # Assumptions: Note: gExitVU is defined in Globals.lib. If you want to
- # override this task reference please do not modify Globals.Lib,
- # override the it by redefining it in Custom.Lib.
- #########################################################################
- #========================================================================
- # History:
- #########################################################################
- TASK ExitVU()
- begin
- exit;
- end;
-